<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/common/meta.jsp"%>
</head>
<body>
	<div class="wrap">
		<div class="header_bg">
			<%@ include file="/common/header.jsp"%>
	    </div>
	    <div class="w">
	    	<div class="path box">
	    		<jsp:include page="/common/frame/frame_path.jsp">
            		<jsp:param name="current" value="订单管理"/>
            	</jsp:include>
	        </div>
	    </div>
	    <div class="main">
	    	<div class="list box">
	        	<div class="pc_left">
	            	<jsp:include page="/common/frame/frame_left.jsp">
	            		<jsp:param name="checked" value="order"/>
	            	</jsp:include>
	            </div>
	            <div class="pc_right">
	                <ul id="list_button_box" class="pc_tit">
	                	<c:choose>
						   <c:when test="${user.host != null}">
								<li class="tit_li1_h" orderType="2">收到的预约</li>
								<li class="tit_li3" orderType="1">已发送预约</li>
								<li class="tit_li2" orderType="3">未处理预约</li>
						   </c:when>
						   <c:otherwise>
								<li class="tit_li1_h" orderType="1">已发送预约</li>
						   </c:otherwise>
						</c:choose>
	                </ul>
	                <table id="framework_main_order_datagrid"></table>
	            </div>
	            <div class="clear"></div>
			</div>
	    </div>
	    <div class="footer_bg">
	    	<%@ include file="/common/footer.jsp"%>
	    </div>
	</div>
<script type="text/javascript">
var orderOptions={
	height:482,
	width:709,
	//fit : true,					//充满上层元素
	fitColumns:true,
	//border:false,
	remoteSort : true,			//定义是否从服务器给数据排序
	pagination : true,			//True就会在 datagrid 的底部显示分页栏。
	//rownumbers : true,			//True就会显示行号的列
	idField : 'id',				//标识字符串 (如果不标明这个属性，getSelections方法不能使用)
	striped : true,				//奇偶行使用不同背景色
       //checkOnSelect : false,		//行选择不映射到复选框
    selectOnCheck : false,		//复选框可以多选
    singleSelect : true,			//之润徐选一行
    url:"${ctx}/order/list_order.do"
};
$("#framework_main_order_datagrid").datagrid(orderOptions);


function selectSentOrder() {
	$("#framework_main_order_datagrid").datagrid({
		queryParams:{},
		columns:[[  
					{field:'id', checkbox:true},
					{field:'statusImg',formatter:frame.getFormatter("OrderStatusImg"), width:40},
					{field:'orderNo', title:'订单编号',width:120,formatter:function(value,row,index){
		       			return "<a href='${ctx}/order/show.do?id=" + row.id + "'>" + value + "</a>";
		       		}}, 
		          	{field:'hostName',title:'店铺',width:180,formatter:function(value,row,index){
		       			return "<a href='${ctx}/order/show.do?id=" + row.id + "'>" + value + "</a>";
		       		}},
		           	{field:'status', formatter:frame.getFormatter("UserOrderStatus"), title:'状态',width:60},  
		           	{field:'lastModifydate', formatter:frame.getFormatter("Time"),title:'时间',width:120}
		       ]]
	});
}
function selectInboxOrder(status) {
	$("#framework_main_order_datagrid").datagrid({
		queryParams:{orderType:"received", untreated:status},
		columns:[[  
				{field:'id', checkbox:true},
				{field:'statusImg',formatter:frame.getFormatter("OrderStatusImg"), width:40},
				{field:'orderNo', title:'订单编号',width:120,formatter:function(value,row,index){
	       			return "<a href='${ctx}/order/show.do?id=" + row.id + "'>" + value + "</a>";
	       		}}, 
           		{field:'userName',title:'来自',width:180,formatter:function(value,row,index){
	       			return "<a href='${ctx}/order/show.do?id=" + row.id + "'>" + value + "</a>";
	       		}},
           		{field:'status', formatter:frame.getFormatter("HostOrderStatus"), title:'状态',width:60},  
           		{field:'lastModifydate', formatter:frame.getFormatter("Time"),title:'时间',width:120}
       ]] 
	});
}

$(function(){
	//初始化按钮点击事件
	$("#list_button_box > li").click(function(){
		$("#list_button_box > li").each(function(i, li){
			if(i==0) {
				$(this).attr("class", "tit_li1");
			} else if($("#list_button_box > li").length-1==i) {
				$(this).attr("class", "tit_li2");
			} else {
				$(this).attr("class", "tit_li3");
			}
		});
		$(this).attr("class", $(this).attr("class") + "_h");
		
		if($(this).attr("orderType") == "1") {
			selectSentOrder();
		} else if($(this).attr("orderType") == "2") {
			selectInboxOrder();
		} else if($(this).attr("orderType") == "3") {
			selectInboxOrder(10);
		}
	});
	<c:choose>
	<c:when test="${user.host != null}">
		selectInboxOrder();
	</c:when>
	<c:otherwise>
		selectSentOrder();
	</c:otherwise>
	</c:choose>
});
</script>
</body>
</html>